#ifndef PGNGAME_H
#define PGNGAME_H
#include <QString>
#include <QVector>

const short pawn = 1;
const short rook = 2;
const short knight = 3;
const short bishop = 4;
const short queen = 5;
const short king = 6;

struct position
{
    int letter;
    int numeric;
};

struct chess_move
{
    position destination;
    short figure; //
    bool mat; //
    bool check; //
    bool is_correct; //
    bool has_source;
    position source;
    bool is_castling; //
    bool is_long_castling; //
    bool is_eating; //
    bool is_white;
    bool is_source_number;
};

struct moves_pair
{
    chess_move white;
    chess_move black;
};

class PGNGame
{
public:
    PGNGame();
    void setEvent(QString eventName);
    void setSite(QString siteName);
    void setDate(QString date);
    void setRound(QString roundNumber);
    void setWhitePlayersName(QString name);
    void setBlackPlayersName(QString name);
    void setMoves(QString movesList);
    void setResult(QString result);
    QString event() const;
    QString site() const;
    QString date() const;
    QString round() const;
    QString whitePlayer() const;
    QString blackPlayer() const;
    QString result() const;
    QString moves() const;
    void debug() const;
    QStringList splitMoves() const;
    int parseMoves();
    void clearPair(moves_pair &pair) const;
    void compileMove(QString &movesText, moves_pair &pair) const;
    QVector<moves_pair> compiledMoves() const;
private:
    position findPosition(QString moveText) const;
    short findFigure(const QChar &letter) const;
    QString m_eventName;
    QString m_siteName;
    QString m_date;
    QString m_roundNumber;
    QString m_whitePlayer;
    QString m_blackPlayer;
    QString m_moves;
    QString m_result;
    QVector<moves_pair> m_parsedMoves;
};

#endif // PGNGAME_H
